<?php
// +----------------------------------------------------------------------
// | [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Author < 931274989@qq.com >
// +----------------------------------------------------------------------
// | Explain 
// +----------------------------------------------------------------------
namespace app\ymkj\controller;

use app\ymkj\controller\Wechat1;
use think\Session;
use think\Db;

class Towxpay extends Controller
{
  public function towxpay() {
    $uid = Session::get('user_auth')['uid'];
    $money = input('recharge_money', '');
    $wechat = new Wechat1();
    $order_sn = MakeOrderSn(); // 设置订单号
    # 添加订单
    $data = array(
            // ...yourdata
    );
    $order_id = db('order')->insertGetId($data);
    if (!$order_id) {
        $this->error('订单添加失败');
    }
    $openid = db('member')->where('uid', $uid)->value('openid');
    $check = $wechat->WeixinPrePay($data, $openid);
    if ($check['status'] == 400) {
         $this->error($check['msg']);
    }
    session::set('zejc_order_id', $order_id);
    $this->assign('jsonData', $check['data']);
    return $this->fetch();  
  }
  
}
?>